#pragma once
#include "gtest/gtest.h"
#include "DataStructure/Input/Property/BeamSectionStandardTypes.h"
#include "../Interface/BarSectionFormulaCalculatorFactory.h"
#include "../Bar/T2SectionFormulaCalculator.h"

using SG::Algebra::Point;
using namespace SG::DataStructure::FEM;
using SG::FEMSolver::Element::BarSectionFormulaCalculatorFactory;
using SG::FEMSolver::Element::T2SectionFormulaCalculator;

// 将 BarSectionFormulaCalculatorFactory 生成对象测试放置在具体截面属性计算中
TEST (BarSectionFormulaCalculatorFactoryTest, T2SectionCalculatorCreate)
{
    // Test data
    auto calculatorPtr = BarSectionFormulaCalculatorFactory::Create (BeamSectionStandardTypes::BEAMSECTYPE_T2);
    auto T2CalculatorPtr = dynamic_cast<T2SectionFormulaCalculator*> (calculatorPtr.get ());

    // Check
    ASSERT_TRUE (nullptr != T2CalculatorPtr);
}

// T2 截面属性计算测试
TEST (BarSectionFormulaCalculatorTest, T2Section)
{
    // Input data
    PBARLData section;
    section.m_id  = 2;
    section.m_mId = 3;
    section.SetGroup ("MSCBML0");
    section.SetBeamSectionStandardTypes (BeamSectionStandardTypes::BEAMSECTYPE_T2);
    section.m_dimension = {5.0, 6.0, 2.0, 1.0};
    section.m_nsm = 10.0;

    // Test data
    T2SectionFormulaCalculator calculator;
    PBARData propertyTest;
    Point centroidTest;
    calculator.Compute (section, _OUT propertyTest, _OUT centroidTest);

    // Target data
    PBARData propertyTarget;
    propertyTarget.m_id  = 2;
    propertyTarget.m_mId = 3;
    propertyTarget.m_A   = 14.0;
    // propertyTarget.m_yS = 0.0;
    // propertyTarget.m_zS = 0.0;
    // propertyTarget.m_yC = 0.8571429;
    // propertyTarget.m_zC = 0.0;
    propertyTarget.m_I1  = 34.38095;
    propertyTarget.m_I2  = 21.16667;
    propertyTarget.m_I12 = 0.0;
    propertyTarget.m_J   = 15.0;
    propertyTarget.m_K1  = 0.2857143;
    propertyTarget.m_K2  = 0.7142857;
    propertyTarget.m_NSM = 10.0;
    propertyTarget.m_FE  = 0.0;
    propertyTarget.SetStressPoints ({4.1428572, 0.5, -1.8571428, 2.5, -1.8571428, -2.5, 4.1428572, -0.5});
    Point centroidTarget;

    // Check
    ASSERT_TRUE (propertyTarget == propertyTest);
    ASSERT_TRUE (centroidTarget == centroidTest);
}